﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace MINERP.CustomerManage.DisposePhoto
{
    public partial class FrmModifyName : Form
    {
        //属性
        public FrmDisposeMain frm { get; set; }
        public string PhotoOldName { get; set; }    //照片原来的名字

        public FrmModifyName()
        {
            InitializeComponent();
        }

        private void FrmModifyName_Load(object sender, EventArgs e)
        {
            txtPhotoName.Text = PhotoOldName;
            btnOK.Focus();
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            string newName = txtPhotoName.Text.Trim();
            if (!newName.Contains("."))
            {
                frm.photoNewName = newName + ".jpg";
                DialogResult = DialogResult.OK;
                this.Close();
            }
            else if (newName.Substring(newName.LastIndexOf(".") + 1) == "jpg" || newName.Substring(newName.LastIndexOf(".") + 1) == "jpeg")
            {
                frm.photoNewName = newName;
                DialogResult = DialogResult.OK;
                this.Close();
            }
            else
            {
                MessageBox.Show("名称的格式不正确，重新输入！", "确定", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }

        private void tsCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
